package com.hot100;

import java.util.HashMap;
import java.util.Map;

public class Solution05 {
    public String longestPalindrome(String s) {
        int left;
        int right;
        int len = s.length();
        int max = 0;
        int index = 0;
        for (int i = 0; i < 2 * len - 1; i++) {
            left = i / 2;
            right = left + i % 2;
            while (left >= 0 && right < len && s.charAt(left) == s.charAt(right)) {
                if (right - left + 1 > max) {
                    index = left;
                    max = right - left + 1;
                }
                left--;
                right++;
            }
        }
        return s.substring(index,index+max);
    }
}
